class Solution:
    def rob(self, nums: list) -> int:
        if not nums:
            return 0
        if len(nums) <= 2:
            return max(nums)
        nums[2] = max(nums[1], nums[0] + nums[2])
        for i in range(3, len(nums)):
            # 100 , 1 ,1,100
            nums[i] = max(nums[i-1], nums[i-2] + nums[i], nums[i-3] + nums[i])
        return nums[-1]
